home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-15 | 5.3 KB | 141 lines | [TEXT/MPS ] |
- //
- // ProgressAtom.c
- //
- // Demonstration of a format2 action atom displaying
- // advancement of the installer dialog progress bar.
- //
- // When the action atom will take a long time to complete its task(s),
- // it is a good idea to present the user with some kind of comforting
- // sign that the machine is performing normally. Using the methods outlined
- // in this example, scriptwriters can show progress in the bar
- // displayed in the installer dialog.
- //
- // Every format2 action atom is allocated 100 increments
- // from the installer progress bar to use as the action atom
- // performs its duties. Error checking is performed by the installer
- // so that even if the action atom requests progress display
- // beyond the 100 allotted increments, the installer will
- // limit the progress to 100 increments.
- //
- // It should be noted that although there are 100 increments
- // alloted to the action atom, progress is not displayed with
- // each and every increment registered from the action atom.
- //
- // mark young • 08/18/94
- //
- // Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
- //
-
- #include <Traps.h>
- #include <Types.h>
- #include <dialogs.h>
- #include <TextUtils.h>
-
- // these lines have been added for Wasabi Installer Debugger support
- #include "CallbackDispatcherHeader.h"
- #include "ActionHandlerHeader.h"
- #include "InstallerMemoryFuncsHeader.h"
-
- // this line replaces #include "ActionAtomIntf.h" used in Installer 3.x action atoms
- #include "ActionAtomHeader.h"
-
- // this is needed for highliting the default button in dialog
- pascal OSErr SetDialogDefaultItem ( DialogPtr theDialog,
- short newItem ) = {0x303C,0x0304,0xAA68};
-
- // this is used to print one line out to the Wasabi Installer Debugger
- void PrintLine( ProcPtr pCallBackProcPtr, Str255 pParam0, Str255 pParam1, Str255 pParam2, Str255 pParam3 );
-
- // external function to send text to Wasabi Installer Debugger
- void RegisterScriptAction( CallBackProcPtr pCallBackProcPtr,
- short actionClassID,
- short actionIdentifier,
- void* param0,
- void* param1,
- void* param2,
- void* param3,
- void* resultPtr );
-
- // print the parameter block record information to Wasabi Installer Debugger
- void PrintAAParamBlock( ActionAtom2PBPtr atomRecPtr );
-
- // NOTE: The name of this function 'ActionAtomFormat2' should
- // match that specified in the -m option for the line in the
- // makefile that compiles this action atom.
- ActionAtomResult ActionAtomFormat2( ActionAtom2PBPtr atomRecPtr )
- {
- short i = 0; // 0..100 progress bar increments
- long lastTickCount = 0; // last check at the time
- long currentTickCount = 0; // this check at the time
-
- // print the parameter block record information to Wasabi Installer Debugger
- PrintAAParamBlock( atomRecPtr );
-
- while ( i < 100 )
- {
- // get the time in ticks
- lastTickCount = currentTickCount = TickCount();
-
- // wait five seconds ( non-CPU specific method )
- while ( currentTickCount < ( lastTickCount + 5 ))
- // keep getting the time in ticks
- currentTickCount = TickCount();
-
- // tell the silly progress bar to move along
- IncrementStatusBar( atomRecPtr->fCallBackProcPtr, 1 );
- i++;
- }
-
- // print the return value to Wasabi Installer Debugger
- PrintLine( atomRecPtr->fCallBackProcPtr, "\p\n",
- "\pProgress Bar Action Atom - done - returning 0 ...", "\p\n", "\p" );
-
- return( 0 );
-
- }
-
- // shoot one line of text out to the Wasabi Installer Debugger
- void PrintLine( ProcPtr pCallBackProcPtr, Str255 pParam0, Str255 pParam1, Str255 pParam2, Str255 pParam3 )
- {
- long theResult;
- RegisterScriptAction( pCallBackProcPtr, kDebuggingAction, kGenericDebugActID, pParam0, pParam1, pParam2, pParam3, &theResult );
- }
-
- void PrintAAParamBlock( ActionAtom2PBPtr atomRecPtr )
- {
- Str255 numStr;
-
- PrintLine( atomRecPtr->fCallBackProcPtr, "\p\n", "\pParameter Block for Progress Bar Action Atom ...", "\p", "\p" );
-
- NumToString( atomRecPtr->fMessageID, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\p", "\pfMessageID : ", numStr, "\p" );
-
- NumToString( (long) atomRecPtr->fStaticDataHdl, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfStaticDataHdl : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fTargetVRefNum, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfTargetVRefNum : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fTargetFolderDirID, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfTargetFolderDirID : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fSystemVRefNum, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfSystemVRefNum : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fSystemBlessedDirID, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfSystemBlessedDirID : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fRefCon, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfRefCon : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fDoingInstall, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfDoingInstall : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fDidLiveUpdate, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfDidLiveUpdate : ", numStr, "\p", "\p" );
-
- NumToString( (long) atomRecPtr->fInstallerTempDirID, numStr );
- PrintLine( atomRecPtr->fCallBackProcPtr, "\pfInstallerTempDirID : ", numStr, "\p", "\p\n" );
-
- }
-